package net.akkz.server.impl;


import net.akkz.server.StringCheck;;

public class StringCheckRegularExpressionImpl implements StringCheck
{
	@Override
	public boolean checkUserid(String userid)
	{
		return userid.matches("^\\d{8}$");
	}

	@Override
	public boolean checkPassword(String password)
	{
		return password.matches("^\\w{6,18}$");
	}

	@Override
	public boolean checkTel(String tel)
	{
		return tel.matches("^\\d{11}$");
	}

	@Override
	public boolean checkQQ(String qq)
	{
		return qq.matches("^\\d{6,10}$");
	}

	@Override
	public boolean checkLength(String str, int length)
	{
		return (str.length() == length);
	}

	@Override
	public boolean checkLength(String str, int start, int end)
	{
		return (str.length() >= start && str.length() <= end);
	}

	@Override
	public boolean checkName(String name)
	{
		return name.matches("^[\\u4e00-\\u9fa5]{2,4}$");
	}

	@Override
	public boolean checkIp(String ip)
	{
		return ip.matches("^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
                    + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
                    + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
                    + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$");
	}

	@Override
	public boolean checkNetMask(String netMask)
	{
		return netMask.matches("^\\d{1,2}$") && (Integer.parseInt(netMask) < 33);
	}

	@Override
	public boolean checkMail(String mail)
	{
		return mail.matches("^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w+)+)$");
	}

}
